import { store } from "@/store";
import { defineStore } from 'pinia'

export const useAppStore = defineStore('pinia-app', {
  state: ():any=> ({ 
    excludeNames: [], // 排除的路由缓存名称
  }),

  actions: {

    updateExcludeNames(val) {
      if (val.type === 'add') {
        if (!this.excludeNames.find((v) => v === val.value)) {
          this.excludeNames.push(val.value)
        }
      } else {
        const resIndex = this.excludeNames.findIndex((v) => v === val.value)
        if (resIndex !== -1) {
          this.excludeNames.splice(resIndex, 1)
        }
      }
    }


   
  },
})

export function useAppStoreHook() {
  return useAppStore(store);
}
